﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Security.Claims;

namespace AdminManager
{
    public class SystemAdminPermissionValueProvider : PermissionValueProvider
    {
        public SystemAdminPermissionValueProvider(IPermissionStore permissionStore) : base(permissionStore)
        {
        }

        public override string Name => "SystemAdmin";

        public async override Task<PermissionGrantResult> CheckAsync(PermissionValueCheckContext context)
        {
            if ( context.Principal?.FindFirst(AbpClaimTypes.Role)?.Value == AdminManagerConsts.AdminRoleName)
            {
                return PermissionGrantResult.Granted;
            }
            return PermissionGrantResult.Undefined;
        }

        public override Task<MultiplePermissionGrantResult> CheckAsync(PermissionValuesCheckContext context)
        {
            throw new NotImplementedException();
        }
    }
}
